<script lang="ts" setup>
import { ref } from 'vue'
import type { ConsultOrderItem } from '@/types/consult'
const { item, previewPre, del } = defineProps<{
  item: ConsultOrderItem
  previewPre: (prescriptionId: string) => void
  del: (id: string) => void
}>()
const showPopover = ref(false)
const actions = [
  { text: '查看处方', disabled: !item.prescriptionId, index: 0 },
  { text: '删除订单', index: 1 }
]
const onSelect = (action: any) => {
  if (action.index === 0) {
    previewPre(item.prescriptionId!)
  }
  if (action.index === 1) {
    del(item.id)
  }
}
</script>

<template>
  <div class="more">
    <van-popover
      v-model:show="showPopover"
      :actions="actions"
      @select="onSelect"
      placement="top-start"
    >
      <template #reference>
        <span>更多</span>
      </template>
    </van-popover>
  </div>
</template>

<style scoped lang="scss">
.more {
  color: var(--cp-tag);
  flex: 1;
  font-size: 13px;
}
</style>
